#include <iostream>
using namespace std;

class Base{
public:
	Base()
		:_b(10){
		++_b;
	}

	virtual void Func1(){
		cout << "Base::Func1()" << endl;
	}

	virtual void Func2(){
		cout << "Base::Func2()" << endl;
	}

	void Func3(){
		cout << "Base::Func3()" << endl;
	}

private:
	int _b = 1;
};

class Derive : public Base{
public:
	virtual void Func1(){
		cout << "Derive::Func1()" << endl;
	}

	virtual void Func4(){
		cout << "Derive::Func4()" << endl;
	}
private:
	int _d = 2;
};

//用程序打印虚表
typedef void(*VF_PTR)();

void PrintVFPTR(VF_PTR* table){
    for (int i = 0; table[i] != nullptr; ++i) {
        printf("[%d]:%p->", i, table[i]);
        VF_PTR f = table[i];
        f();
    }
    cout << endl;
}

int main(){
     Base b;
     Derive d;
     //PrintVFPTR((VF_PTR*)(*(long long*)&b));
     //PrintVFPTR((VF_PTR*)(*(long long*)&d));
     PrintVFPTR(*(VF_PTR**)&b);
     PrintVFPTR(*(VF_PTR**)&d);
     return 0;
}